package com.bwie.controller;

import com.bwie.pojo.GroupActive;
import com.bwie.service.GroupActiveService;
import com.bwie.utils.Result;
import com.bwie.vo.GroupActiveVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @projectName: server-day0718-pay
 * @package: com.bwie.controller
 * @className: ActiveController
 * @author: 陈彤彤
 * @description: TODO
 * @date: 2025/7/27 20:54
 * @version: 1.0
 */
@RestController
@RequestMapping("/active/active")
@Api(tags = "拼团活动管理")
public class ActiveController {

    @Autowired
    GroupActiveService groupActiveService;

    /**
    * @param groupActiveVo:
    * @return Result
    * @author :陈彤彤
    * @description 拼团活动分页列表
    * @date 2025/7/27 20:59
    */
    @ApiOperation(value = "拼团活动分页列表")
    @PostMapping("/groupActiveList")
    public Result groupActiveList(@RequestBody GroupActiveVo groupActiveVo){
        return groupActiveService.groupActiveList(groupActiveVo);
    }

    /**
    * @param groupActive:
    * @return Result
    * @author :陈彤彤
    * @description 添加活动信息
    * @date 2025/7/28 10:50
    */
    @ApiOperation(value = "添加活动信息")
    @PostMapping("/addActive")
    public Result addActive(@RequestBody GroupActive groupActive){
        return groupActiveService.addActive(groupActive);
    }

    /**
    * @param file:
    * @return Result
    * @author :陈彤彤
    * @description 活动文件上传
    * @date 2025/7/28 16:19
    */
    @ApiOperation(value = "活动文件上传")
    @PostMapping("/uploadFile")
    public Result uploadFile(@RequestPart(name = "file")MultipartFile file){
        return groupActiveService.uploadFile(file);
    }

    /**
    * @param activeId:
    * @return Result
    * @author :陈彤彤
    * @description 删除活动信息
    * @date 2025/7/28 16:28
    */
    @ApiOperation(value = "删除活动信息")
    @PostMapping("/deleteByActiveId/{activeId}")
    public Result deleteByActiveId(@PathVariable(name = "activeId")Integer activeId){
        return groupActiveService.deleteByActiveId(activeId);
    }

    /**
    * @param groupActive:
    * @return Result
    * @author :陈彤彤
    * @description 修改活动信息
    * @date 2025/7/28 18:57
    */
    @ApiOperation(value = "修改活动信息")
    @PostMapping("/updateActive")
    public Result updateActive(@RequestBody GroupActive groupActive){
        return groupActiveService.updateActive(groupActive);
    }
}
